﻿$(document).ready(function () {
    $.get("../../Home/GetCateGory", function (data) {
        let str = "";
        for (let i = 0; i < data.length; i++) {
            str += "<li><a href='../../Home/CateGory/" + data[i].id + "'>" + data[i].title + "</a></li>";
        }
        $("#CgList").html(str);

        $.get("../../Home/GetArticle", function (data) {
            let str = "";
            for (let i = 0; i < data.length; i++) {
                str += "<div class='row article-buttom'>";
                str += "<div class='col-md-12'>";
                str += "<div class='article-box'>";

                str += "<a href='../../Home/Article/"+ data[i].id +"' class='article-title-link'>";
                str += "<div class='article-title'>";
                str += "<span>" + data[i].title + "</span>";
                str += "</div>";
                str += "</a>";

                str += "<a href='../../Home/Article/" + data[i].id + "' class='article-details-link'>";
                str += "<div class='row'>";
                str += "<div class='col-md-2 article-img'>";
                str += "<img src='../../../Web/Cover/"+ data[i].photo +"' alt='' width='160px' height='100px'>";
                str += "</div>";
                str += "<div class='col-md-10' style='padding: 0;'>";
                str += "<div class='article-details'>";
                str += "<div class='col-md-10'>";
                str += "<span>" + data[i].context + "</span>";
                str += "</div>";
                str += "</div>";
                str += "</div>";
                str += "</div>";
                str += "</a>";

                str += "<div class='userbox'>";
                str += "<div class='userinfo'>";

                str += "<div>";
                str += "<img src='~/WebImage/userLike.png' alt=''>";
                str += "<span> " + data[i].like + " &nbsp;赞</span>";
                str += "</div>";

                str += "<div>";
                str += "<img src='~/WebImage/userLike.png' alt=''>";
                str += "<span> " + data[i].trample + " &nbsp;踩</span>";
                str += "</div>";

                str += "<div>";
                //str += "<span>" + data[i].author + "</span>";
                str += "<a href='../../../Home/AuthorInfo/" + data[i].id + "'><span>" + data[i].author + "</span></a>";
                str += "</div>";

                str += "</div>";
                str += "</div>";
                str += "</div>";

                str += "</div>";
                str += "</div>";

                $.get("../../Home/GerFLink", function (data)
                {
                    let str = "";
                    str += "<ul>";
                    for (var i = 0; i < data.length; i++)
                    {
                        str += "<li>"+ data[i].title +"</li>";
                    }
                    str += "</ul>";

                    $(".firendLink-context").html(str);

                }, "json");

                $.get("../../Home/GetArticleDate", function (data)
                {
                    let strTop = "";

                    strTop += "<div>";
                    strTop += "<a href='../../Home/Article/" + data[0].id + "'>";
                    strTop += "<img src='../../Web/Cover/" + data[0].photo +"' alt='' style='width: 280px; height: 180px; '>";
                    strTop += "</a>";
                    strTop += "</div>";

                    strTop += "<div class='first-details'>";

                    strTop += "<div class='onceArticle'>";
                    strTop += "<a href='../../Home/Article/" + data[0].id + "'>" + data[0].title + "</a>";
                    strTop += "</div>";

                    strTop += "<div class='onceArticle-details'>";
                    strTop += "<a href='../../Home/Article/" + data[0].id + "'>" + data[0].context + "</a>";
                    strTop += "</div>";

                    strTop += "</div>";

                    let strList = "";

                    for (let i = 1; i < data.length; i++)
                    {
                        strList += "<li>";
                        strList += "<div class='onceArticle-List-title'>";
                        strList += "<a href='../../Home/Article/" + data[i].id + "'>" + data[i].title + "</a>";
                        strList += "</div>";

                        strList += "<div class='onceArticle-List-details'>";
                        strList += "<a href='../../Home/Article/" + data[i].id + "'>" + data[i].context + "</a>";
                        strList += "</div>";
                        strList += "</li>";
                    }


                    $(".Article-date").html(strTop);
                    $(".onceArticle-List > ul").html(strList);
                }, "json");


                $.get("../../Home/GetArticleLike", function (data)
                {
                    let strTop = "";
                    let strList = "";

                    strTop += "<div>";
                    strTop += "<a href='../../Home/Article/" + data[0].id + "'>";
                    strTop += "<img src='../../Web/Cover/" + data[0].photo +"' alt='' style='width: 280px; height: 180px; '>";
                    strTop += "</a>";
                    strTop += "</div>";

                    strTop += "<div class='first-details'>";

                    strTop += "<div class='onceArticle'>";
                    strTop += "<a href='../../Home/Article/" + data[0].id + "'>" + data[0].title + "</a>";
                    strTop += "</div>";

                    strTop += "<div class='onceArticle-details'>";
                    strTop += "<a href='../../Home/Article/" + data[0].id + "'>" + data[0].context + "</a>";
                    strTop += "</div>";

                    strTop += "</div>";

                    for (let i = 1; i < data.length; i++)
                    {
                        strList += "<li>";

                        strList += "<div class='onceArticle-List-Like-title'>";
                        strList += "<a href='../../Home/Article/" + data[i].id + "'>" + data[i].title + "</a>";
                        strList += "</div>";

                        strList += "<div class='onceArticle-List-Like-details'>";
                        strList += "<a href='../../Home/Article/" + data[i].id + "'>" + data[i].context + "</a>";
                        strList += "</div>";
                        strList += "</li>";
                    }

                    $(".Article-Like").html(strTop);
                    $(".onceArticle-List-Like > ul").html(strList);
                });

            }
            $(".article-context").html(str);

        }, "json");

    }, "json");

});
